import request from '@/utils/request'
const prefixUrl = process.env.VUE_APP_SUPERSET_SERVER
/**
 * 优惠券列表
 * http://192.168.88.247:4999/web/#/80/1887
 * @param {Object} params
 * @returns
 */
export function getCouponList (data) {
  return request({
    url: '/api/v1/coupon/list',
    method: 'post',
    data
  })
}
/**
 * 优惠券新增
 * http://192.168.88.247:4999/web/#/80/1885
 * @param {Object} data
 * @returns
 */
export function addCoupon (data) {
  return request({
    url: '/api/v1/coupon/add',
    method: 'post',
    data
  })
}
/**
 * 优惠券编辑
 * http://192.168.88.247:4999/web/#/80/1886
 * @param {Object} data
 * @returns
 */
export function updateCoupon (data) {
  return request({
    url: '/api/v1/coupon/update',
    method: 'put',
    data
  })
}
/**
 * 优惠券状态更新
 * http://192.168.88.247:4999/web/#/80/1888
 * @param {Object} data
 * @returns
 */
export function updateCouponStatus (data) {
  return request({
    url: '/api/v1/coupon/status',
    method: 'put',
    data
  })
}
/**
 * 优惠券删除
 * http://192.168.88.247:4999/web/#/80/1918
 * @param {Object} data
 * @returns
 */
export function delCoupon (data) {
  return request({
    url: '/api/v1/coupon/delete',
    method: 'delete',
    data
  })
}

/**
 * 优惠券统计数据
 * http://192.168.88.247:4999/web/#/80/1922
 * @returns
 */
export function getReportData (params = {}) {
  return request({
    url: prefixUrl + 'api/v2/data_report/chart/data',
    params,
    timeout: 0
  })
}
/**
 * 创建优惠券导出任务
 * http://showdoc.wisetimes.cn:4999/web/#/80?page_id=3212
 * @param {*} data
 * @returns
 */
export function createExportCouponTask (data) {
  return request({
    url: '/api/v1/coupon/export',
    method: 'post',
    data
  })
}

/**
 * 获取优惠券导出任务结果
 * http://showdoc.wisetimes.cn:4999/web/#/80/3213
 * @param {*} params
 * @returns
 */
export function queryExportCouponTask (params) {
  return request({
    url: '/api/v1/coupon/export_task',
    method: 'get',
    params
  })
}
